from django.contrib import admin
from django.utils.html import format_html

from flashsale.models import *
# Register your models here.

class ProductAdmin(admin.ModelAdmin):
    list_display = ('id','product_img','model','name','price','rank','endurance','charge','count')
    ordering = ('id',)

    def product_img(self, obj):

        return format_html('<img src="/{}" style="width:100px;height:auto;">', obj.img)


class ProductImageAdmin(admin.ModelAdmin):
    list_display = ('id','product_images','product')
    ordering = ('id',)
    def product_images(self, obj):
        return format_html('<img src="/{}" style="width:100px;height:auto;">', obj.images)

admin.site.register(Product, ProductAdmin)
admin.site.register(ProductImage, ProductImageAdmin)